
#ifndef TIMER_MANAGE_HPP
#define TIMER_MANAGE_HPP

#include "Timer.hpp"
#include <sys/epoll.h>
#include <thread>
#include <map>
#include <unordered_map>
#include <vector>
#include<unistd.h>
using namespace std;

namespace zhb
{
    class TimerMap
    {
    private:
        int m_epollfd;
        std::vector<struct epoll_event> m_events;
        std::unordered_map<int, zhb::Timer> m_timers;
        bool m_stop;
        static const int eventsize = 16;
        std::thread m_workerThread;

    public:
        TimerMap();
        ~TimerMap();
        bool init(int timeout);
        bool add_timer(Timer &tv);
        void remove_timer(Timer &tv);
        bool loop(int timeout);
        void set_stop();
    };

} // namespace tulun

#endif